package cn.enzo.yun.service.impl;


import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.enzo.utils.service.CommonServiceImpl;
import cn.enzo.yun.dao.UserDao;
import cn.enzo.yun.domain.User;
import cn.enzo.yun.service.IUserService;

@Service
public class UserServiceImpl extends CommonServiceImpl<User> implements IUserService {

	@Autowired
	private UserDao userDao;
	
	@Override
	public Integer deleteBykey(Object key) throws Exception{
		User selectByKey = userDao.selectByKey(key);
		selectByKey.setIsdelete(true);
		return userDao.update(selectByKey);
	}

	@Override
	public User selectByKey(Object key) throws Exception{
		return userDao.selectByKey(key);
	}
	
	@Override
	public Integer save(User entity) throws Exception{
		entity.setCreatetime(new Date());
		entity.setIsdelete(false);
		return userDao.save(entity);
	}
	
	@Override
	public List<User> queryByCondition(User entity) throws Exception {
		entity.setIsdelete(false);
		return userDao.queryByCondition(entity);
	}
}
